Merged
Conversation
Add a sleep primitive composed by an asm entry point and a rust function, save the current task context and compute awake tick
Sleep is more a task public API fn than a primitive type
…te dispatch to be aware of that
…rom sleep to this one
… interrupt to awake the blocked task
…to avoid log flooding
… task primitives module
Add a small description, and very trivial documentation on all current primitives types. If I haven't forgot any.
Not working, driving me crazy
The ROM is not really used for now in test mode so it's ok I guess
Testing the invariants from sleep primitive, from the blocked queue and the timer interrupt
Add run queue check for invariants
…e and timing_helpers to documentation Split the primitives documentation to have more separate logic documentation, data structure and timing helpers are not primitives so there's should not be in the primitives documentation.
…eep test behavior Add the info header to primitives task file to keep track of what is tested at this point, update the task sleep test behavior to skipped to not always running it
Add sleep and delay for task handling
…o test Change the BUFFER static to RUN_QUEUE static using a config static for max size, add a basic idle task, static, no change possible for the dev calling it, and update the main function to create task and test. Need sleep primitive to continue on this branch
…e context_switch test
The CpusState structure will be used to store all useful flags per CPU core. Like scheduler flags, state flags, and more if needed.
…, fix task context to use correct mstatus value Task context mstatus has been update to use 6152 instead of 8 to enable M-mode on task,for now at least
Things are smelly, like if two task with different priority print, it can cause race condition and corrupt uart driver leading to a complete kernel crash(mcause = 7), but if the print or logging system is protected with a mutex, or while printing, we deactivate interrupt, there's no problem.
…ng mstatus from context routine
No runtime starting for now, execute the task manually
…eue and remove mstatus in task context
…es, remove unused import and variable
…trap-frame-reset Improve dispatch to a real scheduler using preemption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements and documentation to the kernel, focusing on enhanced task management, scheduler functionality, and core kernel data structures. It adds comprehensive documentation for kernel primitives, data structures, scheduler, and timing helpers, introduces new assembly routines for task sleeping and context management, and updates task and context structures to support more robust scheduling and blocking mechanisms. Additionally, linker and configuration changes expand available memory and feature flags.
Key changes include:
Documentation Additions and Improvements
Documentation/kernel/data_structure.md,Documentation/kernel/primitives.md,Documentation/kernel/scheduler.md,Documentation/kernel/timing_helpers.md). [1] [2] [3] [4]Documentation/kernel/task.md). [1] [2] [3] [4]Task and Scheduler Enhancements
TaskBlockControlenum and integrated it into theTaskstruct to better represent blocked task reasons and states (Documentation/kernel/task.md).Documentation/kernel/task.md,Cargo.toml). [1] [2]TaskContextstruct to include new fields (ra,mstatus) for more accurate context switching and status tracking (Documentation/kernel/task.md,src/arch/riscv32/task/task_context.rs). [1] [2]mstatusappropriately for interrupt enabling (src/arch/riscv32/task/task_context.rs).Assembly and Context Switch Improvements
sleep.S), improved context save/restore (save_context.S,restore_context.S), and updated trap entry/exit logic for preemptive scheduling and correct status management (src/arch/riscv32/asm/sleep.S,src/arch/riscv32/asm/save_context.S,src/arch/riscv32/asm/restore_context.S,src/arch/riscv32/asm/trap_entry.S). [1] [2] [3] [4] [5]src/arch/riscv32/asm/yield.S).src/arch/riscv32/asm/mod.rs,src/arch/riscv32/mod.rs). [1] [2]Feature Flags and Build Configuration
Cargo.toml.linkers/linker_test_mode.ld).0.4.5(Cargo.toml).Utilities and Helpers
mhartidCSR (src/arch/riscv32/helpers.rs).These changes collectively improve the kernel's robustness, documentation, and scheduling capabilities, making it easier to maintain, extend, and understand.